import { _decorator, AudioClip, AudioSource, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('AudioManager')
export class AudioManager extends Component {

    private static instance: AudioManager;
    public static get Instance(): AudioManager {
        return this.instance;
    }

    @property([AudioClip])
    clips: AudioClip[] = [];

    audio: AudioSource;

    protected onLoad(): void {
        AudioManager.instance = this;
        this.audio = this.getComponent(AudioSource);
    }

    start() {

    }

    update(deltaTime: number) {

    }

    PlayShoot(num: number, volume = 1) {
        this.audio.playOneShot(this.clips[num], volume);
    }

    PlayReload(volume = 1) {
        this.audio.playOneShot(this.clips[5], volume);
    }

    PlayNoAmmo() {
        this.audio.playOneShot(this.clips[6]);
    }

    PlayHurt(volume = 1) {
        this.audio.playOneShot(this.clips[7], volume);
    }

    PlayMetalHurt(volume = 1) {
        this.audio.playOneShot(this.clips[10], volume);
    }

}


